from testudo import Assert
import exceptions

class MockTestFixtureWith0Test():
	pass
		
class MockTestFixtureWith3Tests_():
	def test_method_1(self):
		pass
	
	def test_method_2(self):
		pass
		
	def test_method_3(self):
		pass
		
	def non_test_method(self):
		pass
	
class MockTestFixtureWith1PassingAnd1FailingTests_():
	def test_passing(self):
		pass;
		
	def test_failing(self):
		Assert.fail("Failed.")
		
class MockTestFixtureWith1PassingAnd1IgnoredTests_():
	def test_passing(self):
		pass;
		
	def test_ignored(self):
		Assert.ignore()

class MockTestFixtureWithoutSetUpAndTearDown():
	def __init__(self):
		self.invoked_methods = []
	
	def test_method_1(self):
		self.invoked_methods.append("test_method_1")
	
	def test_method_2(self):
		self.invoked_methods.append("test_method_2")
	
class MockTestFixtureWithSetUpAndTearDown():
	def __init__(self):
		self.invoked_methods = []
	
	def set_up(self):
		self.invoked_methods.append("set_up")
	
	def tear_down(self):
		self.invoked_methods.append("tear_down")
	
	def test_method_1(self):
		self.invoked_methods.append("test_method_1")
	
	def test_method_2(self):
		self.invoked_methods.append("test_method_2")
		
class MockTestFixtureWithTearDownAndFailingTest():
	def __init__(self):
		self.invoked_methods = []
		
	def tear_down(self):
		self.invoked_methods.append("tear_down")
		
	def test_fails(self):
		self.invoked_methods.append("test_fails")
		Assert.fail("Failed")
		
class MockTestFixtureWithTearDownAndExceptionInSetUp():
	def __init__(self):
		self.invoked_methods = []
		
	def set_up(self):
		self.invoked_methods.append("set_up")
		raise TestException("fail")
		
	def tear_down(self):
		self.invoked_methods.append("tear_down")
		
	def test_success(self):
		self.invoked_methods.append("test_success")

		
class MockTestFixtureWithSuccessfulTest():
	def test_success(self):
		Assert.is_true(True)
		
class MockTestFixtureWithFailingTest():
	def test_fail(self):
		Assert.fail("message")
		
class MockTestFixtureWithException():
	def test_exception(self):
		raise TestException("exception message")

class MockTestFixtureWithIgnoredTest():
	def test_ignored(self):
		Assert.ignore("ignore message")

class TestException(exceptions.Exception):
	def __init__(self, message):
		self.message = message
		
	def __str__( self ):
		return self.__class__.__name__ + ": " + self.message
		